package com.alibaba.citrus.ots.platform.enhance.functions.diff.sap.dataParser;

import com.alibaba.citrus.ots.platform.enhance.functions.diff.common.constant.SalesOrderDiffStandardFieldDict;
import com.alibaba.citrus.ots.platform.enhance.functions.diff.common.dataParser.DataParser;
import com.alibaba.citrus.ots.platform.enhance.repository.model.diff.common.FieldLineDTO;
import com.alibaba.cz.base.tool.log.Log;
import com.epoch.app.otsapplicationadaptersdk.sap.MnReceiverCommSDO;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hanguo
 * @date 2022/1/25
 * @Description SapIf006SDO数据解析
 */
@Component
public class SapIf006SDODataParse extends DataParser {

    /**
     * 日志
     */
    private static Log log = Log.getLogger(SapIf006SDODataParse.class);

    /**
     * 数据库字段，映射成对账处理的业务字段(标准字段)
     * key：报文中的字段，value：转换后的字段,这里的 value 字段也不要重复
     */
    private static Map<String, String> dataBaseFiledMapping = new HashedMap();

    static {
        dataBaseFiledMapping.put("outerKey", SalesOrderDiffStandardFieldDict.SAP_SALES_ORDER_ID.getFieldCode());
        dataBaseFiledMapping.put("success",SalesOrderDiffStandardFieldDict.SAP_006_SUCCESS.getFieldCode());
        dataBaseFiledMapping.put("innerKey",SalesOrderDiffStandardFieldDict.OTS_SALES_ORDER_ID.getFieldCode());
        //dataBaseFiledMapping.put("message",SalesOrderDiffStandardFieldDict.SAP_006_MESSAGE.getFieldCode());


    }


    @Override
    public Map<String, FieldLineDTO> parse(Object obj) {
        Map<String, FieldLineDTO> map = new HashMap<>();
        if (obj instanceof MnReceiverCommSDO) {
            MnReceiverCommSDO mnReceiverCommSDO = (MnReceiverCommSDO) obj;
            return obtainFieldLineMap(dataBaseFiledMapping, mnReceiverCommSDO, mnReceiverCommSDO.getClass());
        }
        return map;
    }

    @Override
    public String obtainProcessType() {
        return "MnReceiverCommSDO";
    }
}
